/**
 * @author        hejiyang <silentmanager@163.com>
 * @date          2024-11-09 23:52:04
 * Copyright © YourCompanyName All rights reserved
 */
import request from '@/config/axios'

// 更新酒水管理
export const updateDrinkInventory = async (data) => {
  return await request.put({ url: `/bms/drink-inventory/update`, data })
}

// 创建酒水管理
export const createDrinkInventory = async (data) => {
  return await request.post({ url: `/bms/drink-inventory/create`, data })
}

export interface DrinkItem {
  id: number // 唯一标识符
  drinkCode: string // 饮品代码
  drinkName: string // 饮品名称
  price: number // 价格
  revenue: number // 销售额
  bottleCount: number // 瓶数
  packageCount: number // 包装数量
  stock: number // 库存
  bonusRule: string // 奖励规则
  isListed: boolean // 是否上架
  createTime: string // 创建时间，格式为 YYYY-MM-DD HH:MM:SS
}
export interface DrinkInventoryUpdateRequest {
  drinkId: string
  quantityChange: number
}
// 获得酒水管理分页
export const pageDrinkInventory = async (params) => {
  return await request.get<{ list: DrinkItem[]; total: number }>({
    url: `/bms/drink-inventory/page`,
    params
  })
}
// 更新酒水库存
export const updateStockApi = async (params: DrinkInventoryUpdateRequest) => {
  return await request.put({ url: `/bms/drink-inventory/update-stock` ,params})
}

// 获得酒水管理
export const getDrinkInventory = async (id: string) => {
  return await request.get({ url: `/bms/drink-inventory/get?id=${id}` })
}

// 导出酒水管理 Excel
export const exportExcelDrinkInventory = async (params) => {
  return await request.get({ url: `/bms/drink-inventory/export-excel`, params })
}

// 删除酒水管理
export const deleteDrinkInventory = async (id: number) => {
  return await request.delete({ url: `/bms/drink-inventory/delete?id=${id}` })
}
